@use '@material/list' as mdc-list;
@use '@material/theme/theme' as mdc-theme;
@use '../../mdc-helpers/mdc-helpers';
@use '../../../material/core/theming/theming';

@mixin color($config-or-theme) {
  $config: theming.get-color-config($config-or-theme);

  @include mdc-helpers.mat-using-mdc-theme($config) {
    .mat-mdc-optgroup-label {
      // Since this will usually be rendered in an overlay,
      // we have explicitly set the default color.
      @include mdc-theme.prop(color, text-primary-on-background);
      @include mdc-list.deprecated-item-disabled-text-color(
        mdc-list.$deprecated-text-disabled-color, $query: mdc-helpers.$mat-theme-styles-query);
    }
  }
}

@mixin typography($config-or-theme) {
  $config: theming.get-typography-config($config-or-theme);
}

@mixin density($config-or-theme) {
  $density-scale: theming.get-density-config($config-or-theme);
}

@mixin theme($theme-or-color-config) {
  $theme: theming.private-legacy-get-theme($theme-or-color-config);
  @include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-optgroup') {
    $color: theming.get-color-config($theme);
    $density: theming.get-density-config($theme);
    $typography: theming.get-typography-config($theme);

    @if $color != null {
      @include color($color);
    }
    @if $density != null {
      @include density($density);
    }
    @if $typography != null {
      @include typography($typography);
    }
  }
}
